package com.bian.Userdao;

import com.bian.pojo.User;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public class Userdaoimpl implements Userdao{
private JdbcTemplate jdbcTemplate;

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    @Override
    public User findUser(User user) {
        try {
            String sql = "select username from user where username=? and password=?";
            User query = jdbcTemplate.queryForObject(sql,
                    new BeanPropertyRowMapper<User>(User.class),user.getUsername(),user.getPassword());
            return query;
        }catch (Exception exception){
        }
        return null;
    }


}
